<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
<meta http-equiv="X-UA-Compatible" content="IE=9"/>
<meta name="generator" content="Doxygen 1.8.13"/>
<meta name="viewport" content="width=device-width, initial-scale=1"/>
<title>PID plotter component: PID-Plotter</title>
<link href="tabs.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="jquery.js"></script>
<script type="text/javascript" src="dynsections.js"></script>
<link href="search/search.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="search/searchdata.js"></script>
<script type="text/javascript" src="search/search.js"></script>
<link href="doxygen.css" rel="stylesheet" type="text/css" />
</head>
<body>
<div id="top"><!-- do not remove this div, it is closed by doxygen! -->
<div id="titlearea">
<table cellspacing="0" cellpadding="0">
 <tbody>
 <tr style="height: 56px;">
  <td id="projectalign" style="padding-left: 0.5em;">
   <div id="projectname">PID plotter component
   &#160;<span id="projectnumber">1.0</span>
   </div>
   <div id="projectbrief">ESP-IDF component for pid plotter</div>
  </td>
 </tr>
 </tbody>
</table>
</div>
<!-- end header part -->
<!-- Generated by Doxygen 1.8.13 -->
<script type="text/javascript">
var searchBox = new SearchBox("searchBox", "search",false,'Search');
</script>
<script type="text/javascript" src="menudata.js"></script>
<script type="text/javascript" src="menu.js"></script>
<script type="text/javascript">
$(function() {
  initMenu('',true,false,'search.php','Search');
  $(document).ready(function() { init_search(); });
});
</script>
<div id="main-nav"></div>
</div><!-- top -->
<!-- window showing the filter options -->
<div id="MSearchSelectWindow"
     onmouseover="return searchBox.OnSearchSelectShow()"
     onmouseout="return searchBox.OnSearchSelectHide()"
     onkeydown="return searchBox.OnSearchSelectKey(event)">
</div>

<!-- iframe showing the search results (closed by default) -->
<div id="MSearchResultsWindow">
<iframe src="javascript:void(0)" frameborder="0" 
        name="MSearchResults" id="MSearchResults">
</iframe>
</div>

<div class="header">
  <div class="headertitle">
<div class="title">PID-Plotter </div>  </div>
</div><!--header-->
<div class="contents">
<div class="textblock"><ul>
<li>ESP-IDF component for <a href="https://github.com/VedantParanjape/pid-tuning-gui">pid-tuning-gui</a>. This transports data, between the plotter and esp device.</li>
</ul>
<h1>Requirements</h1>
<ul>
<li><a href="https://github.com/VedantParanjape/logger">logger</a></li>
</ul>
<h1>Installation</h1>
<pre class="fragment">cd &lt;your_esp_idf_project&gt;
mkdir components
cd components
git clone https://github.com/VedantParanjape/logger   
git clone https://github.com/VedantParanjape/pid-plotter-component pid_plotter
</pre><p><em>Change CMakeList.txt to add the line given below:</em> </p><pre class="fragment">set(EXTRA_COMPONENT_DIRS &lt;path_to_component_folder&gt;)
</pre><h1>How to use</h1>
<ul>
<li>Set UDP and TCP server IP address and port in menuconfig, under component config</li>
<li>Set wifi ssid and password to use.</li>
<li>include "pid_plotter.h"</li>
<li><code><a class="el" href="plotter_8h.html#acc8c0bc33035955e5c765b474fb33ef1" title="Wrapper function to run the plotter functionality on a separate core. ">plotter()</a></code> must be called in app_main</li>
<li><code>send_to_queue(pid_data_struct)</code> must be used to push pid_data struct to the message queue, by passing such a struct to this function, this data will be sent to client for plotting.</li>
<li><code><a class="el" href="transport_8h.html#aa37b5765ca807a54890c516c916e7e9b" title="Returns pid_const_data struct. Checks if the resource is blocked by mutex for writing or it is access...">pid_const_read()</a></code> returns the <a class="el" href="structpid__const.html">pid_const</a> struct received from user.</li>
</ul>
<h1>Working</h1>
<ul>
<li>PID Constants (Kp, Ki, Kd, and setpoint) are received by esp32, by connecting to a tcp server.</li>
<li>TCP server should send the values as a json string. <div class="fragment"><div class="line">{</div><div class="line">    &quot;Kp&quot; : 1.0,</div><div class="line">    &quot;Ki&quot; : 2.0,</div><div class="line">    &quot;Kd&quot; : 3.0,</div><div class="line">    &quot;SetPoint&quot; : 4.0</div><div class="line">}</div><div class="line"></div><div class="line">PID constants json format</div></div><!-- fragment --></li>
<li>Calculated PID values (P, I, D, current, error) are sent by esp32 through udp, sent to a udp server.</li>
<li>Values are sent as a json string through UDP. <div class="fragment"><div class="line">{</div><div class="line">    &quot;P&quot; : 1.0,</div><div class="line">    &quot;I&quot; : 2.0,</div><div class="line">    &quot;D&quot; : 3.0,</div><div class="line">    &quot;current&quot; : 4.0,</div><div class="line">    &quot;error&quot; : 5.0</div><div class="line">}</div><div class="line"></div><div class="line">PID data json format</div></div><!-- fragment --> <h1>Example Code</h1>
</li>
</ul>
<div class="fragment"><div class="line"><span class="preprocessor">#include &quot;<a class="code" href="pid__plotter_8h.html">pid_plotter.h</a>&quot;</span></div><div class="line"></div><div class="line"><span class="keywordtype">void</span> broad()</div><div class="line">{</div><div class="line">    <span class="keyword">struct </span><a class="code" href="structpid__terms.html">pid_terms</a> dt;</div><div class="line">    dt.<a class="code" href="structpid__terms.html#ab4c7f8712a43d4fe1b8932783f286c22">current</a> = 1.00;</div><div class="line">    dt.error = 2.00;</div><div class="line">    dt.P = 3.00;</div><div class="line">    dt.I = 4.00;</div><div class="line">    dt.D = 5.00;</div><div class="line"></div><div class="line">    <span class="keywordflow">while</span>(1)</div><div class="line">    {</div><div class="line">        esp_err_t err = <a class="code" href="transport_8h.html#a3d23daa4cae5ba60d838c8a2b785462e">send_to_queue</a>(dt);</div><div class="line">        err = <a class="code" href="transport_8h.html#a3d23daa4cae5ba60d838c8a2b785462e">send_to_queue</a>(dt);</div><div class="line">        logD(<span class="stringliteral">&quot;main&quot;</span>, <span class="stringliteral">&quot;%f&quot;</span>, <a class="code" href="transport_8h.html#aa37b5765ca807a54890c516c916e7e9b">pid_const_read</a>().setpoint);</div><div class="line">        vTaskDelay(10);</div><div class="line">    }</div><div class="line">}</div><div class="line"></div><div class="line"><span class="keywordtype">void</span> app_main(<span class="keywordtype">void</span>)</div><div class="line">{</div><div class="line">    xTaskCreate(broad, <span class="stringliteral">&quot;send&quot;</span>, 4096, NULL, 1, NULL);</div><div class="line">    <a class="code" href="plotter_8h.html#acc8c0bc33035955e5c765b474fb33ef1">plotter</a>();</div><div class="line">}</div></div><!-- fragment --> <h1>Detailed documentation</h1>
<ul>
<li><a href="https://vedantparanjape.github.io/pid-plotter-component/">https://vedantparanjape.github.io/pid-plotter-component/</a> </li>
</ul>
</div></div><!-- contents -->
<!-- start footer part -->
<hr class="footer"/><address class="footer"><small>
Generated by &#160;<a href="http://www.doxygen.org/index.html">
<img class="footer" src="doxygen.png" alt="doxygen"/>
</a> 1.8.13
</small></address>
</body>
</html>
